<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>扬尘监测设备基本信息上传</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <blockquote class="layui-elem-quote layui-text">
            鉴于小伙伴的普遍反馈，先温馨提醒两个常见“问题”：1. <a href="/doc/base/faq.html#form" target="_blank">为什么select/checkbox/radio没显示？</a> 2. <a href="/doc/modules/form.html#render" target="_blank">动态添加的表单元素如何更新？</a>
        </blockquote>

        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>上传扬尘设备基本信息到工务署</legend>
        </fieldset>

        <form class="layui-form" action="">
            
              <div class="layui-form-item">
                <label class="layui-form-label">设备编号</label>
                <div class="layui-input-inline">
                    <input type="password" name="device_no" lay-verify="device_code" placeholder="请输入设备号" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">请填写24-32位设备号</div>
            </div>
            
            
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">设备安装日期</label>
                    <div class="layui-input-inline">
                        <input type="text" name="device_installation_date" id="date" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">请填写设备安装日期</div>
                </div>
            </div>

            
            <div class="layui-form-item">
                <label class="layui-form-label">设备名称(例如：13#监测点)</label>
                <div class="layui-input-block">
                    <input type="text" name="name" autocomplete="off" placeholder="(非必填)，请尽量完善信息" class="layui-input">
                </div>
            </div>
            
            
            
            <div class="layui-form-item">
                <label class="layui-form-label">设备类型(1&0环境)(非必填)</label>
                <div class="layui-input-block">
                    <input type="radio" name="type" value="1" title="设备类型(1.环境监测)" checked="">
                </div>
            </div>
            
            
            <div class="layui-form-item">
                <label class="layui-form-label">监测项(非必填)</label>
                <div class="layui-input-block">
                    <input type="text" name="me_option" autocomplete="off" placeholder="(非必填)，但请尽量完善信息" class="layui-input">
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">安装位置</label>
                <div class="layui-input-block">
                    <input type="text" name="install_address" autocomplete="off" placeholder="(非必填)，但请尽量完善信息" class="layui-input">
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">设备安装单位(非必填)</label>
                <div class="layui-input-block">
                    <input type="text" name="install_company" autocomplete="off" placeholder="(非必填)，但请尽量完善信息" class="layui-input">
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">状态(非必填)</label>
                <div class="layui-input-block">
                    <input type="text" name="state" autocomplete="off" placeholder="(非必填)，但请尽量完善信息" class="layui-input">
                </div>
            </div>
            
            
              <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交至DAO后台</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>

        <!-- 示例-970 -->
        <ins class="adsbygoogle" style="display:inline-block;width:970px;height:90px" data-ad-client="ca-pub-6111334333458862" data-ad-slot="3820120620"></ins>


    </div>
</div>

<script src="../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../../../js/jquery-3.2.1.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1'
        });

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
        	device_code: function (value) {
                if (value.length < 24) {
                    return '设备号至少得24位';
                }
            }
           
        });


        //监听提交
        form.on('submit(demo1)', function (data) {
          //  layer.alert(JSON.stringify(data.field), {
          //      title: '最终的提交信息'
          //  })
            
            $.ajax({
        type: 'post',
        url: "'<%=basePath%>'page/ToFormDataOne",
        data: JSON.stringify(data.field),
        success: function (res) {
            if (res) {
            	alert(res);
            	layer.alert(JSON.stringify(data.field));
            } else {
                layer.alert("into else");
            }
        }
    });
            
            return false;
        });

        //表单初始赋值
        form.val('example', {
            "username": "贤心" // "name": "value"
            , "password": "123456"
            , "interest": 1
            , "like[write]": true //复选框选中状态
            , "close": true //开关状态
            , "sex": "女"
            , "desc": "我爱 layui"
        })


    });
</script>

</body>
</html>